package com.example.controller;

import com.example.service.ConsultService;
import com.example.service.StreamConsultService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author Blue
 * @version 1.0
 */
@RestController
@RequiredArgsConstructor
public class ChatController {

    private final ConsultService consultService;
    private final StreamConsultService streamConsultService;

    @RequestMapping("/chat")
    public String chat(String message){
        return consultService.chat(message);
    }

    @RequestMapping(value = "/chat/tream",produces = "text/html;charset=utf-8")
    public Flux<String> chatInStream(String message){
        return streamConsultService.chat(message);
    }

    @RequestMapping(value = "/chat/memory",produces = "text/html;charset=utf-8")
    public Flux<String> chatInMemory(
            @RequestParam String memoryId,
            @RequestParam String message
    ){
        return streamConsultService.chatInMemory(memoryId, message);
    }
}
